welcome = {}
-- INPUT
function welcome:Input(startfun) end
-- OUTPUT
function welcome:Show() end -- show dialog
function welcome:Hide() end -- hide dialog

----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------

-- PRIVATE
welcome.parent = nil
welcome.layer = nil
welcome.startfun = nil

function welcome:Input(startfun)
    self.startfun = startfun
end

-- PUBLIC
function welcome:Show()
    self.parent = GetMainScene()
    if self.layer == nil then
        self:CreateLayer()
    end
    self.layer:setVisible(true)
end

-- PUBLIC
function welcome:Hide()
    if self.layer then
        self.layer:setVisible(false)
    end
end

-- PRIVATE
function welcome_OnStartGame()
    welcome:Hide()
    welcome.startfun()
    --PlayLayer.parent = welcome.layer:getParent();
    --PlayLayer:Start(pplCfg.init_row0_y);
end

-- PRIVATE
function welcome:CreateLayer()
    self.layer = CCLayer:create()

    -- bg
    local sprite = CCSprite:create("png/startbg.png")
    sprite:setPosition(CCPointMake(pplCfg.RESOLUTION.width/2, pplCfg.RESOLUTION.height/2))
    self.layer:addChild(sprite)

    local item1 = CCMenuItemImage:create("png/start1.png", "png/start2.png")
    item1:registerScriptTapHandler(welcome_OnStartGame)
    item1:setPosition(0, -100);

    local menu = CCMenu:create()
    menu:addChild(item1)
    --menu:setPosition(0.0, 0.0)
    --menu:addChild(item2)
    self.layer:addChild(menu)

    self.parent:addChild(self.layer, 1)
end
